Skip to content

Keep the kit's C# in Source/*.cs, copied into ParallelKit.ps1 by a build script - #106

Merged
HalRiveria merged 2 commits into
mainfrom
build/csharp-source
Dec 2, 2026
Merged

HalRiveria merged 2 commits into
mainfrom
build/csharp-source

Conversation

@HalRiveria-Bot

@HalRiveria-Bot HalRiveria-Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

About 1,000 lines of C# sat in three Add-Type -TypeDefinition here-strings in ParallelKit.ps1. No editor treated them as C#, and nothing compiled them before the kit loaded or reported compiler warnings and analyzer findings, since Add-Type doesn't show warnings.

The C# now lives in Source/, one file per block, named after the type that guards it: PkConsoleCtrl.cs, PkConsoleQuickEdit.cs and PkChildProcessJob.cs. Build/Update-ParallelKitCSharp.ps1 copies them into the blocks. ParallelKit.ps1 stays committed, self-contained, and the file attached to each release, so nothing changes for users. The C# itself is unchanged: the copy reproduces ParallelKit.ps1 byte for byte, so TypesVersion stays at 14.

The script:

  • with no switch, updates ParallelKit.ps1 from Source/ and leaves everything outside the three blocks alone.
  • -Check exits 1 if ParallelKit.ps1 doesn't match Source/.
  • -Compile builds each file on its own, as Add-Type does, twice. First with the .NET Framework's csc.exe as C# 5, the compiler Add-Type uses on Windows PowerShell 5.1; then with the .NET SDK at LangVersion 5, for the .NET that pwsh runs on, with a short list of analyzer rules about real faults. Warnings are errors in both.
  • refuses, with a message: a block without its file or a file without its block, a line starting with '@ (which would end the here-string), and a file that isn't UTF-8.

A new CI job, C#, runs -Check -Compile. It isn't a required check. The required harness checks catch a stale copy anyway: the new harness section BN runs -Check, and tests the update and the refusals on a copy of the kit in %TEMP%.

Testing

Windows PowerShell 5.1 PowerShell 7
Full harness all passed (734 assertions) all passed (734 assertions)
-AsModule -Section MODULE passed (289 assertions) passed (289 assertions)
Update-ParallelKitCSharp.ps1 -Check -Compile passed passed

After the review fixes (the last commit, which only touches the build script), section BN and -Check -Compile were run again on both versions and passed. The full harness wasn't rerun locally after that commit; CI runs it.

-Compile was also run against copies with one problem each, and failed on every one: a C# 6 feature (interpolated string), an analyzer finding (CA2200, throw e;) and a compiler warning (an unused variable). A copy in a folder with ; and %20 in its path compiled correctly, and a copy with an invalid UTF-8 byte was refused with a message naming the file.

The new C# job hasn't run on a GitHub runner before. Its SDK step targets the .NET that the runner's pwsh uses, so it needs a matching SDK on the image. This pull request's run will show whether one is there.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits December 2, 2026 01:38
…arallelKit.ps1

The C# in ParallelKit.ps1's three Add-Type blocks now lives in Source/<Type>.cs, one file per block. Build/Update-ParallelKitCSharp.ps1 copies them into the .ps1, which stays committed and stays the release asset: -Check fails if they differ, and -Compile builds each file with the .NET Framework's csc.exe as C# 5 and with the .NET SDK for pwsh's .NET, with warnings as errors and a short list of analyzer rules. The C# itself is unchanged.

A new CI job, C#, runs both. Harness section BN checks the copy matches and tests the script's checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a copy of each .cs file

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria
HalRiveria merged commit 919ce06 into main Dec 2, 2026
6 checks passed
@HalRiveria
HalRiveria deleted the build/csharp-source branch December 2, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants